package com.ruoyi.ifmDepartmentTitle.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ifmDepartmentTitle.domain.IfmDepartmentTitle;
import com.ruoyi.ifmDepartmentTitle.service.IIfmDepartmentTitleService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;

import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 部职别Controller
 *
 * @author ruoyi
 * @date 2024-10-31
 */
@RestController
@RequestMapping("/system/IfmDepartmentTitle")
public class IfmDepartmentTitleController extends BaseController
{
    @Autowired
    private IIfmDepartmentTitleService ifmDepartmentTitleService;

    /**
     * 查询部职别列表
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:list')")
    @GetMapping("/list")
    public TableDataInfo list(IfmDepartmentTitle ifmDepartmentTitle)
    {
        startPage();
        List<IfmDepartmentTitle> list = ifmDepartmentTitleService.selectIfmDepartmentTitleList(ifmDepartmentTitle);
        return getDataTable(list);
    }

    /**
     * 导出部职别列表
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:export')")
    @Log(title = "部职别", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, IfmDepartmentTitle ifmDepartmentTitle)
    {
        List<IfmDepartmentTitle> list = ifmDepartmentTitleService.selectIfmDepartmentTitleList(ifmDepartmentTitle);
        ExcelUtil<IfmDepartmentTitle> util = new ExcelUtil<IfmDepartmentTitle>(IfmDepartmentTitle.class);
        util.exportExcel(response, list, "部职别数据");
    }

    /**
     * 获取部职别详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:query')")
    @GetMapping(value = "/{titleId}")
    public AjaxResult getInfo(@PathVariable("titleId") Long titleId)
    {
        return success(ifmDepartmentTitleService.selectIfmDepartmentTitleByTitleId(titleId));
    }

    /**
     * 新增部职别
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:add')")
    @Log(title = "部职别", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody IfmDepartmentTitle ifmDepartmentTitle)
    {
        return toAjax(ifmDepartmentTitleService.insertIfmDepartmentTitle(ifmDepartmentTitle));
    }

    /**
     * 修改部职别
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:edit')")
    @Log(title = "部职别", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody IfmDepartmentTitle ifmDepartmentTitle)
    {
        return toAjax(ifmDepartmentTitleService.updateIfmDepartmentTitle(ifmDepartmentTitle));
    }

    /**
     * 删除部职别
     */
    @PreAuthorize("@ss.hasPermi('system:IfmDepartmentTitle:remove')")
    @Log(title = "部职别", businessType = BusinessType.DELETE)
	@DeleteMapping("/{titleIds}")
    public AjaxResult remove(@PathVariable Long[] titleIds)
    {
        return toAjax(ifmDepartmentTitleService.deleteIfmDepartmentTitleByTitleIds(titleIds));
    }
}
